OpenIdConnectAuthenticationHandler: message.State is null or empty 您所在的位置:网站首页 idea pathstring OpenIdConnectAuthenticationHandler: message.State is null or empty

OpenIdConnectAuthenticationHandler: message.State is null or empty

2023-04-14 15:20| 来源: 网络整理| 查看: 265

百度翻译此文   有道翻译此文 问题描述

I am using UseOpenIdConnectAuthentication middleware for ASP.Net Core application to authenticate against Dells Cloud access manager token provider (setup to provide OpenId/OAuth2 authentication). Following is the code:

app.UseCookieAuthentication(new CookieAuthenticationOptions { AutomaticAuthenticate = true, AutomaticChallenge = true, AuthenticationScheme = "ClientCookie", CookieName = CookieAuthenticationDefaults.CookiePrefix + "ClientCookie", ExpireTimeSpan = TimeSpan.FromMinutes(5), LoginPath = new PathString("/signin"), LogoutPath = new PathString("/signout") }); app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions { RequireHttpsMetadata = false, SaveTokens = true, ClientId = "XYZClient_Id", ClientSecret = "XYZ_ClientSecret", ResponseType = OpenIdConnectResponseType.Code, PostLogoutRedirectUri = "https://example.com", Configuration = new OpenIdConnectConfiguration { AuthorizationEndpoint = "https://CAM.COM/CloudAccessManager/RPSTS/OAuth2/Default.aspx", TokenEndpoint = "https://CAM.COM/CloudAccessManager/RPSTS/OAuth2/Token.aspx", UserInfoEndpoint = "https://CAM.COM/CloudAccessManager/RPSTS/OAuth2/User.aspx", Issuer= "urn:CAM.COM/CloudAccessManager/RPSTS", } });

But I am stuck at one point for a few hours now. I get the following error:

SecurityTokenInvalidSignatureException: IDX10500: Signature validation failed. There are no security keys to use to validate the signature

I am getting code and state back in url querystring https://example.com/signin-oidc?code=somecode&state=somestate

Any type of guidance is appreciated.

UPDATE Added Issuer Signing key:

TokenValidationParameters = new TokenValidationParameters { IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetValue("AppSettings:ClientSecret"))) } 推荐答案

The error you're seeing is caused by the fact you're not using the OpenID Connect provider configuration discovery feature offered by the OIDC middleware, that allows it to retrieve the cryptographic keys used to sign identity tokens.

If your provider supports this feature, remove the entire Configuration node and set Authority instead. All the endpoints should be automatically registered for you.

If it doesn't support this feature, you'll have to manually add the signing keys to OpenIdConnectOptions.TokenValidationParameters.IssuerSigningKeys.



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有